package com.cg.asm.body.controller.help;

import com.alibaba.fastjson.JSONObject;
import com.cg.asm.body.config.loading.cache.menu.IMenuCache;
import com.cg.asm.body.config.loading.cache.org.IOrgCache;
import com.cg.asm.client.CommonUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/help/setting")
public class SysSettingController {

    private IMenuCache menuCache;
    private IOrgCache orgCache;

    public SysSettingController(IMenuCache menuCache, IOrgCache orgCache) {
        this.menuCache = menuCache;
        this.orgCache = orgCache;
    }

    @ApiOperation(value = "刷新功能清单缓存", notes = "功能清单")
    @GetMapping("/refreshMenu")
    public JSONObject refreshMenu() {
        menuCache.initMenuPointsAndRole();
        return CommonUtil.successJson("功能清单缓存刷新完成");
    }

    @ApiOperation(value = "刷新组织机构缓存", notes = "组织机构")
    @GetMapping("/refreshOrg")
    public JSONObject refreshOrg() {
        orgCache.initOrgTreeData();
        return CommonUtil.successJson("组织机构缓存刷新完成");
    }
}
